*Relevant other programs and associated datasets:
*1.method_2.do
*  mpr_intensity (inpatient)
*  mpr_treats
*  outp_intensity (hospital outpatient)
*  op_treats
*  bcar_intensity (office-based outpatient)
*  car_treats
*2.reshape_method.do
*  medpar_all_file_reshaped (inpatient)
*  outpatient_base_claims_reshaped (hospital outpatient)
*  bcarrier_claims_j_reshaped (office-based outpatient)
*3.reshape_method_pt2.do
*	 outpatient_base_claims_j_flagged (hospital outpatient)
*	 bcarrier_claims_j_flagged (office-based outpatient)
*	 medpar_all_file_flagged (inpatient)

*This program Collects the relevant claims data into a single folder and organizes it
* by inpatient; hospital outpatient; and office-based ambulatory

set more off
capture log close
global path "N:\MedicareClaims-P045601-BE\Work\"
global dataIn "N:\MedicareClaims-P045601-BE\Work\hosp_retro\health_out\Data-In"


foreach yr of numlist 2005/2012 {
 
*OFFICE-BASED OUTPATIENT
*Intermediate reshape
  use "$path\`yr'\bcarrier_claims_j_reshaped.dta", clear
   save "$dataIn\bcarrier_claims_`yr'_reshaped.dta", replace
	 clear

*Flagged  
 use "$path\`yr'\bcarrier_claims_j_flagged.dta", clear
  save "$dataIn\bcarrier_claims_`yr'_flagged.dta", replace 
clear

*Treated
 use "$path\`year'\car_treats.dta", clear
  save "$dataIn\car_treats_`yr'.dta", replace 
clear
  
*Intensity
  use "$path\`yr'\bcar_intensity", clear
   save "$dataIn\bcar_intensity_`yr'.dta", replace 
 clear


***HOSPITAL***
*INPATIENT 
*Intermediate reshape
  use "$path\`yr'\medpar_all_file_reshaped.dta", clear
   save "$dataIn\medpar_all_file_reshaped_`yr'.dta", clear
	 clear

*Flagged  
 use "$path\`yr'\medpar_all_file_flagged.dta", clear
  save "$dataIn\medpar_all_file_flagged_`yr'.dta", replace 
clear

*Treated
 use "$path\`yr'\mpr_treats.dta", clear
  save "$dataIn\mpr_treats_`yr'.dta", replace 
	
*Intensity
  use "$path\`yr'\mpr_intensity.dta", clear
   save "$dataIn\mpr_intensity_`yr'.dta", replace 
  clear
  
 
*HOSPITAL OUTPATIENT 
*Intermediate reshape
  use "$path\`yr'\.dta", clear
   save "$dataIn\outpatient_base_claims_reshaped_`yr'.dta", replace
	 clear

*Flagged   
 use "$path\`yr'\outpatient_base_claims_j_flagged.dta", clear
  save "$dataIn\outpatient_base_claims_`yr'_flagged.dta", replace 
clear

*Treated
 use "$path\`yr'\op_treats.dta", clear
  save "$dataIn\op_treats_`yr'.dta", replace 
	
*Intensity
  use "$path\`yr'\outp_intensity.dta", clear
   save "$dataIn\outp_intensity_`yr'.dta", replace 
  clear

}
